﻿/*
* BaseSkill.h
*
* 技能基类
*
* create date: 2014.4.11
* create by: leo
*
*/

#include "BaseSkill.h"

USING_NS_CC;
USING_NS_CC_EXT;

//
CBaseSkill::CBaseSkill(const char* paramString)
: mOnActCallbackObj(this),
  mArmature(NULL),
  mShadowArmature(NULL),
  mAniIndex(0),
  mOnActCallback(callfuncO_selector(CBaseSkill::doNothing)),
  mOnFinishCallbackObj(this),
  mOnFinishCallback(callfuncO_selector(CBaseSkill::doNothing)),
  mEffectCount(0),
  mAimType(ENEMY),
  mEffectRange(0)
{}

CBaseSkill::CBaseSkill(Param& param)
: mOnActCallbackObj(this),
  mArmature(NULL),
  mShadowArmature(NULL),
  mAniIndex(0),
  mOnActCallback(callfuncO_selector(CBaseSkill::doNothing)),
  mOnFinishCallbackObj(this),
  mOnFinishCallback(callfuncO_selector(CBaseSkill::doNothing)),
  mEffectCount(0),
  mAimType(ENEMY),
  mEffectRange(0),
  mParam(param)
{

}

CBaseSkill::~CBaseSkill()
{}

CBaseSkill::SkillEffectType CBaseSkill::getSkillEffectType()
{
	return mParam.EffectType;
}

int CBaseSkill::getSkillEffectValue()
{
	return mParam.EffectValue;
}

bool CBaseSkill::isCrit()
{
	return (CCRANDOM_0_1() > 0.8);
}

void CBaseSkill::setOnSkillActCallback(cocos2d::CCObject* callbackObj, cocos2d::SEL_CallFuncO callback)
{
	mOnActCallbackObj = callbackObj;
	mOnActCallback = callback;
}

void CBaseSkill::setOnSkillFinishCallback(cocos2d::CCObject* callbackObj, cocos2d::SEL_CallFuncO callback)
{
	mOnFinishCallbackObj = callbackObj;
	mOnFinishCallback = callback;
}

cocos2d::CCString CBaseSkill::getSkillName()
{
	return mParam.SkillName;
}

void CBaseSkill::setSkillName(const char* name)
{
	mParam.SkillName.initWithFormat("%s", name);
}

void CBaseSkill::setArmature(CHeroArmature& armature, int index)
{
	mArmature = &armature;
	mAniIndex = index;
}

void CBaseSkill::setShadowArmature(CHeroArmature& armature, int index)
{
	mShadowArmature = &armature;
	//mAniIndex = index;
}

void CBaseSkill::doNothing(cocos2d::CCNode* obj)
{}

void CBaseSkill::onFrameEvent(CCBone *bone, const char *evt, int originFrameIndex, int currentFrameIndex)
{}

void CBaseSkill::selectTargets()
{}
